package com.hm.service.framework.base;

import com.hm.service.utils.EncryptionUtils;
import com.hm.service.utils.response.ResponseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class BaseEncryption {

    private static final Logger logger = LoggerFactory.getLogger(BaseEncryption.class);

    //秘钥
    private static final String secretKey_v1 = "kokL8G4RmNfV69cdcJ9dfnrlFGsLy6mH";

    //只要请求成功都加密返回
    protected static <T> String generateSucceed(T data) {
        String resp = ResponseUtils.generateSucceed(data);
        return EncryptionUtils.encrypt(secretKey_v1, resp);
    }

    //只要请求成功都加密返回
    protected static <T> String generateFail(String des) {
        String resp = ResponseUtils.generateFail(des);
        return EncryptionUtils.encrypt(secretKey_v1, resp);
    }

    //只要请求成功都加密返回
    protected static <T> String generateFailForCode(String code, String des) {
        String resp = ResponseUtils.generateFailForCode(code, des);
        return EncryptionUtils.encrypt(secretKey_v1, resp);
    }


    protected static String BaseDecrypt(String content) {
        return EncryptionUtils.decrypt(secretKey_v1, content);
    }

}
